package com.bysj.lms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bysj.lms.pojo.entity.Class;
import com.bysj.lms.mapper.ClassMapper;
import com.bysj.lms.service.IClassService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaojiakai
 * @since 2022-02-04
 */
@Service
public class ClassServiceImpl extends ServiceImpl<ClassMapper, Class> implements IClassService {

    @Autowired
    ClassMapper classMapper;

    @Override
    public PageInfo findByPage(String name, int page, int count) {
        PageHelper.startPage(page,count);
        QueryWrapper<Class> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(name) && StringUtils.isNotEmpty(name),"name",name);
        List<Class> classes = classMapper.selectList(queryWrapper);
        return new PageInfo(classes);
    }
    
}
